package com.jingle;


import java.util.ResourceBundle;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class GameView extends SurfaceView implements SurfaceHolder.Callback{

	CrazyDiamondsActivity cda=null;
	GameViewDrawThread gvd=null;
	GameViewGoThread gvg=null;
	Bitmap qipan=null;
	Bitmap red=null;
	public GameView(CrazyDiamondsActivity cda) {
		super(cda);
		this.cda=cda;
		getHolder().addCallback(this);
		gvd=new GameViewDrawThread(this,getHolder());
		gvg=new GameViewGoThread(this);
		initBitmap(cda);
	}
	
	private void initBitmap(Context context){
		Resources r=context.getResources();
		qipan=BitmapFactory.decodeResource(r, R.drawable.qipan);
		red=BitmapFactory.decodeResource(r, R.drawable.b);
	}
	public void DoDraw(Canvas canvas){
		canvas.drawBitmap(qipan, 0, 0,null);
		canvas.drawBitmap(red, 41, 100,null);
	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		// TODO Auto-generated method stub
		gvd.setFlag(true);
		if (!gvd.isAlive()) {
			gvd.start();
		}
		
		gvg.setFlag(true);
		if (!gvg.isAlive()) {
			gvg.start();
		}
		
		
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder) {
		// TODO Auto-generated method stub
		
	}

}
